package it.giulio.oracle;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;

import org.apache.log4j.Logger;

public class OracleLoggableStatement implements Statement {
    // Variabile per il logger
	private Logger loggerWrapper = Logger.getLogger(OracleLoggableStatement.class);

    private Statement wrappedStatement;
    private String batchSQLString = "";

    public OracleLoggableStatement(Connection connection) throws SQLException {
        wrappedStatement = connection.createStatement();
    }

    public OracleLoggableStatement(Connection connection, int resultSetType, int resultSetConcurrency) throws SQLException {
        wrappedStatement = connection.createStatement(resultSetType, resultSetConcurrency);
    }

    public OracleLoggableStatement(Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
        wrappedStatement = connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
    }

    public void close() throws SQLException {
        wrappedStatement.close();
    }

    public boolean execute(String p0, String[] p1) throws SQLException {
        loggerWrapper.debug(p0);
        return wrappedStatement.execute(p0, p1);
    }

    public boolean execute(String p0, int p1) throws SQLException {
        loggerWrapper.debug(p0);
        return wrappedStatement.execute(p0, p1);
    }

    public boolean execute(String p0) throws SQLException {
        loggerWrapper.debug(p0);
        return wrappedStatement.execute(p0);
    }

    public boolean execute(String p0, int[] p1) throws SQLException {
        loggerWrapper.debug(p0);
        return wrappedStatement.execute(p0, p1);
    }

    public void addBatch(String p0) throws SQLException {
        wrappedStatement.addBatch(p0);
        batchSQLString += (p0 + ";\n");
    }

    public void cancel() throws SQLException {
        wrappedStatement.cancel();
    }

    public void clearBatch() throws SQLException {
        wrappedStatement.clearBatch();
        batchSQLString = "";
    }

    public void clearWarnings() throws SQLException {
        wrappedStatement.clearWarnings();
    }

    public int[] executeBatch() throws SQLException {
        loggerWrapper.debug(batchSQLString);
        return wrappedStatement.executeBatch();
    }

    public ResultSet executeQuery(String p0) throws SQLException {
        loggerWrapper.debug(p0);
        return wrappedStatement.executeQuery(p0);
    }

    public int executeUpdate(String p0, int[] p1) throws SQLException {
        loggerWrapper.debug(p0);
        return wrappedStatement.executeUpdate(p0, p1);
    }

    public int executeUpdate(String p0) throws SQLException {
        loggerWrapper.debug(p0);
        return wrappedStatement.executeUpdate(p0);
    }

    public int executeUpdate(String p0, String[] p1) throws SQLException {
        loggerWrapper.debug(p0);
        return wrappedStatement.executeUpdate(p0, p1);
    }

    public int executeUpdate(String p0, int p1) throws SQLException {
        loggerWrapper.debug(p0);
        return wrappedStatement.executeUpdate(p0, p1);
    }

    public Connection getConnection() throws SQLException {
        return wrappedStatement.getConnection();
    }

    public int getFetchDirection() throws SQLException {
        return wrappedStatement.getFetchDirection();
    }

    public int getFetchSize() throws SQLException {
        return wrappedStatement.getFetchSize();
    }

    public ResultSet getGeneratedKeys() throws SQLException {
        return wrappedStatement.getGeneratedKeys();
    }

    public int getMaxFieldSize() throws SQLException {
        return wrappedStatement.getMaxFieldSize();
    }

    public int getMaxRows() throws SQLException {
        return wrappedStatement.getMaxRows();
    }

    public boolean getMoreResults() throws SQLException {
        return wrappedStatement.getMoreResults();
    }

    public boolean getMoreResults(int p0) throws SQLException {
        return wrappedStatement.getMoreResults(p0);
    }

    public int getQueryTimeout() throws SQLException {
        return wrappedStatement.getQueryTimeout();
    }

    public ResultSet getResultSet() throws SQLException {
        return wrappedStatement.getResultSet();
    }

    public int getResultSetConcurrency() throws SQLException {
        return wrappedStatement.getResultSetConcurrency();
    }

    public int getResultSetHoldability() throws SQLException {
        return wrappedStatement.getResultSetHoldability();
    }

    public int getResultSetType() throws SQLException {
        return wrappedStatement.getResultSetType();
    }

    public int getUpdateCount() throws SQLException {
        return wrappedStatement.getUpdateCount();
    }

    public SQLWarning getWarnings() throws SQLException {
        return wrappedStatement.getWarnings();
    }

    public void setCursorName(String p0) throws SQLException {
        wrappedStatement.setCursorName(p0);
    }

    public void setEscapeProcessing(boolean p0) throws SQLException {
        wrappedStatement.setEscapeProcessing(p0);
    }

    public void setFetchDirection(int p0) throws SQLException {
        wrappedStatement.setFetchDirection(p0);
    }

    public void setFetchSize(int p0) throws SQLException {
        wrappedStatement.setFetchSize(p0);
    }

    public void setMaxFieldSize(int p0) throws SQLException {
        wrappedStatement.setMaxFieldSize(p0);
    }

    public void setMaxRows(int p0) throws SQLException {
        wrappedStatement.setMaxRows(p0);
    }

    public void setQueryTimeout(int p0) throws SQLException {
        wrappedStatement.setQueryTimeout(p0);
    }
	
}
